#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 0x3f3f3f3f;
const ll maxn= 1e5+10;
int main(){
	int a,b;
	cin>>a>>b;
	int count=0;
	if(a<=b){
		cout<<b-a<<endl;
	}else{
		while(a>=b){
			if(a%2==0){
				a=a/2;
			}else{
				a+=1; 
			}
			count++;
		}
		cout<<count+b-a<<endl;
	}
	


	return 0;
}

